home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_09_08
/
9n08098a
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
Text File
|
1991-06-15
|
382 b
|
19 lines
int wordcount(char *str)
{
int count = 0;
char *s;
s=str;
while(*s && *s==' ')
s++; //Skip leading spaces
while(s)
{
s=strchr(s,' '); //Find the first word break
while(*s && *s==' ')
s++; //Allow for multiple spaces
count++; //Increment count - Note it starts as 0 not 1
}
return(count);
}